/**
 * @param {number[]} nums
 * @return {number}
 */
var firstMissingPositive = function (nums) {
  let a = []
  nums.forEach(item => {
    if (item > 0) {
      a[item] = item
    }
  })
  if (a.length === 0) return 1
  let c = a.findIndex((_, index) => index > 0 && !a[index])
  return c === -1 ? a.length : c
}
console.log(firstMissingPositive([0]))
